<?php
/**
 * @filesource					HoldOrderAction.class.php
 * @desc						寄存位销售类
 *
 * @author						张召
 * @copyright					zhangzhao@huigeyuan.com
 * @date						2011-05-12
 */

class HoldOrderAction extends CommonAction{
	/**
	 * 销售信息展示
	 */
	public function index(){
		$crumb_info = array(
			array('uri' => '__URL__/index', 'title' => L('list_hold_order'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/add', 'title' => L('add_hold_order')),
			);
		$hold_order = new HoldOrderModel();
		$hold_order_list = $hold_order->getHoldOrderList();

		$this->assign('hold_order_list', $hold_order_list);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);

		$this->display();
	}
	/**
	 * 新增寄存位销售
	 */
	public function add(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('hold_order_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/add', 'title' => L('add_hold_order'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_hold_order')),
			);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		//自动生成寄存位编号
		$holdorder = new HoldOrderModel();
		$info = $holdorder->order('id desc')->limit(1,1)->find();
		$request_id = 'JCW'.date('Ymd',time()).substr('10000000'+$info[id]+1,1);
		$this->assign('request_id',$request_id);

		$id = $_POST['jcwid'];
		$holdplace = new HoldPlaceModel();
		$place = $holdplace->where("id=$id")->find();
		$this->assign('place',$place);
		$this->display();
	}
	/**
	 * 寄存位销售详细信息展示
	 */
	public function show(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('hold_order_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/show/id/' . $_REQUEST['id'], 'title' => L('show'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_hold_order')),
			);
		$hold_order = new HoldOrderModel();
		$hold_order_info = $hold_order->getHoldOrderInfo($_REQUEST['id']);

		$this->assign('hold_order_info', $hold_order_info);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		$this->display();
	}

	/**
	 * 寄存位销售详细信息更改
	 */
	public function edit(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('hold_order_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/edit/id/' . $_REQUEST['id'], 'title' => L('edit_hold_place'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_hold_order')),
			);

		$hold_order = new HoldOrderModel();
		$hold_order_info = $hold_order->getHoldOrderInfo($_REQUEST['id']);

		$this->assign('hold_order_info', $hold_order_info);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		$this->display();
	}


    /**
	 * 寄存位退够列表
	 */
	public function return_request(){
		$crumb_info = array(
			array('uri' => '__URL__/return_request', 'title' => L('list_hold_request'), 'sort' => C('CRUMB_LAST')),
		);
        $this->_mergeCrumbInfo($crumb_info);
		$hold_request = new HoldOrderModel();
		$hold_request_list = $hold_request->getHoldRequestList();

		$this->assign('hold_request_list', $hold_request_list);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);

		$this->display();
	}
	/**
	 *寄存位退够
	 */
	public function quit(){
		$crumb_info = array(
			array('uri' => '__URL__/return_request', 'title' => L('hold_request_manage'), 'sort' => C('CRUMB_DEFAULT')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/return_request', 'title' => L('list_hold_request'))
			);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
        $hold_request = new HoldOrderModel();
		$hold_request_info = $hold_request->getHoldOrderInfo($_REQUEST['id']);

		$this->assign('hold_request_info', $hold_request_info);
		$this->display();
	}
    /**
	 * 寄存位退够详细信息展示
	 */
	public function view(){
		$crumb_info = array(
			array('uri' => '__URL__/return_request', 'title' => L('hold_request_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/view/id/' . $_REQUEST['id'], 'title' => L('show'), 'sort' => C('CRUMB_LAST')),
		);
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array(
			array('uri' => '__URL__/index', 'title' => L('list_hold_request')),
			);
		$hold_request = new HoldOrderModel();
		$hold_request_info = $hold_request->getHoldOrderInfo($_REQUEST['id']);

		$this->assign('hold_request_info', $hold_request_info);
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		$this->display();
	}


    /**
	 *假删除
	 *状态改为-1
	 */
	public function del(){
		$name=$this->getActionName();
		$model = M ($name);
		if (! empty ( $model )) {
			$pk = $model->getPk ();
			$id = $_REQUEST [$pk];
			if (isset ( $id )) {
				$condition = array ($pk => array ('in', explode ( ',', $id ) ) );
				//放入回收站
				$list=$model->where ( $condition )->setField ( 'status', - 1 );
				if ($list!==false) {
					$this->success ('删除成功！' );
				} else {
					$this->error ('删除失败！');
				}
			} else {
				$this->error ( '非法操作' );
			}
		}
	}

}
?>